﻿namespace IBTrader.Modules.Binarize
{
    using System;
    using System.IO;

    class BinarizerHistorical : Binarizer
    {
        protected override void WriteLine(BinaryWriter writer, string[] parts)
        {
            if (parts.Length != 9) return;// throw new ArgumentException("Invalid length", "parts");

            var cnt = int.Parse(parts[0], ci);
            var dt = DateTime.Parse(parts[1], ci);
            var open = float.Parse(parts[2], ci);
            var high = float.Parse(parts[3], ci);
            var low = float.Parse(parts[4], ci);
            var close = float.Parse(parts[5], ci);
            var volume = int.Parse(parts[6], ci);
            var price = float.Parse(parts[7], ci);
            var _ = int.Parse(parts[8], ci);

            writer.Write((int)dt.TimeOfDay.TotalSeconds);
            writer.Write(price);
            writer.Write(open);
            writer.Write(high);
            writer.Write(low);
            writer.Write(close);
            writer.Write(volume);
        }
    }
}
